package com.zw.yzk.kabu.data.repository;

import com.zw.yzk.kabu.data.network.ServiceGenerator;
import com.zw.yzk.kabu.data.network.entity.GoodsOrderDetailsEntity;
import com.zw.yzk.kabu.data.network.service.GoodsOrderDetailService;
import com.zw.yzk.kabu.data.network.task.GoodsOrderDetailsTask;
import com.zw.yzk.kabu.data.network.task.Task;

import javax.inject.Inject;

import rx.Observable;
import rx.functions.Func1;

/**
 * Created by zhanwei on 2017/1/12.
 */

public class GoodsOrderDetailsRepository extends CommonRepository {

    @Inject
    public GoodsOrderDetailsRepository() {
    }

    @Override
    protected Observable connectServer(Task task) {
        GoodsOrderDetailService service = ServiceGenerator.createService(GoodsOrderDetailService.class);
        GoodsOrderDetailsTask goodsTask = (GoodsOrderDetailsTask) task;

        return service.getGoodsOrderDetails(
                goodsTask.orderId,
                goodsTask.type,
                goodsTask.userId,
                goodsTask.accessToken);

    }

    @Override
    protected Func1<GoodsOrderDetailsEntity, Observable> getServerData() {
        return new Func1<GoodsOrderDetailsEntity, Observable>() {
            @Override
            public Observable call(GoodsOrderDetailsEntity entity) {
                return Observable.just(entity);
            }
        };
    }

}
